package com.orange.config;

import com.orange.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Emp
 * @projectName: springboot
 * @package: com.orange.config
 * @className: LogAutoConfiguration
 * @description: TODO
 * @date: 2021/12/6 18:42
 * @version: 1.0
 */
@Configuration
public class LoginConfiguration implements WebMvcConfigurer {

    @Bean
    public LoginInterceptor loginInterceptor(){
        return new LoginInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        List<String> excludes  = new ArrayList<>();
        excludes.add("/login/doLogin.do");
        excludes.add("/login/toLogin.do");
        excludes.add("/captcha.do");
        excludes.add("/resources/**");
        excludes.add("/index.html");
        excludes.add("/swagger-ui/** ");
        registry.addInterceptor(loginInterceptor()).addPathPatterns("/**").excludePathPatterns(excludes);
    }
}
